from selenium import webdriver
from selenium.webdriver.common.by import By

browser = webdriver.Chrome()
browser.get("https://movie.douban.com/top250")

# 定位到标签
li_list =browser.find_elements(By.XPATH,'//ol[@class="grid_view"]/li')

# 遍历标签列表，获取标签中的文本内容
for li in li_list:
    a_href = li.find_element(By.XPATH,'.//div[@class="pic"]/a').get_attribute('href')
    print('详情页地址：', a_href)
    pic_url = li.find_element(By.XPATH,'.//div[@class="pic"]/a/img').get_attribute('src')
    print('图片地址：',pic_url)
    movie_name = li.find_element(By.XPATH,'.//div[@class="info"]/div[@class="hd"]/a/span[1]')
    print('电影名称：',movie_name.text)

browser.quit()
